DP_GRAV
Overview
The DP_GRAV function calculates the gravitational pressure drop component for single-phase flow in inclined pipes and channels. This pressure change arises from the elevation difference between two points in a piping system and is a critical factor when designing pipelines that traverse varying terrain or include vertical sections.
This function wraps the one_phase_dP_gravitational method from the fluids library, an open-source Python package for chemical, mechanical, and civil engineering calculations. For complete documentation, see the fluids.friction module.
The gravitational pressure drop is calculated using the hydrostatic pressure formula adapted for inclined flow:
\Delta P_{grav} = \rho \cdot g \cdot L \cdot \sin(\theta)
where \rho is the fluid density (kg/m³), g is gravitational acceleration (m/s², default 9.80665), L is the pipe length (m), and \theta is the pipe angle relative to horizontal (degrees). A positive angle indicates upward flow, which produces a positive pressure drop (pressure loss), while a negative angle indicates downward flow, resulting in pressure recovery.
When L=1 (the default), the function returns the differential pressure drop per unit length (Pa/m), useful for integration along variable-inclination pipe segments. For discrete calculations with a known pipe length, the function returns the total gravitational pressure change (Pa).
Unlike frictional pressure drop which always opposes flow direction, gravitational pressure change depends solely on elevation change and fluid density. For vertical upward flow (\theta = 90°), the full hydrostatic head applies; for horizontal flow (\theta = 0°), there is no gravitational component. This separation of pressure drop components—gravitational, frictional, and acceleration—follows the standard approach in fluid mechanics analysis.
This example function is provided as-is without any representation of accuracy.
Excel Usage
=DP_GRAV(angle, rho, L, g)
angle(float, required): Pipe angle relative to horizontal [degrees]rho(float, required): Fluid density [kg/m³]L(float, optional, default: 1): Pipe length [m]g(float, optional, default: 9.80665): Gravitational acceleration [m/s²]
Returns (float): Gravitational pressure drop. If L=1, returns per unit length [Pa/m]; otherwise total [Pa]. Returns error message (str) if input is invalid.
Examples
Example 1: Horizontal pipe (no gravitational drop)
Inputs:
| angle | rho |
|---|---|
| 0 | 1000 |
Excel formula:
=DP_GRAV(0, 1000)
Expected output:
0
Example 2: Upward flow at 45 degrees (water)
Inputs:
| angle | rho |
|---|---|
| 45 | 1000 |
Excel formula:
=DP_GRAV(45, 1000)
Expected output:
6934.2
Example 3: Downward flow at -30 degrees (oil)
Inputs:
| angle | rho | L |
|---|---|---|
| -30 | 850 | 10 |
Excel formula:
=DP_GRAV(-30, 850, 10)
Expected output:
-41678
Example 4: Vertical pipe (90 degrees, air)
Inputs:
| angle | rho | L | g |
|---|---|---|---|
| 90 | 2.6 | 4 | 9.80665 |
Excel formula:
=DP_GRAV(90, 2.6, 4, 9.80665)
Expected output:
101.99
Python Code
import micropip
await micropip.install(["fluids"])
from fluids.friction import one_phase_dP_gravitational as fluids_dp_grav
def dp_grav(angle, rho, L=1, g=9.80665):
"""
Calculate gravitational pressure drop component for single-phase flow in inclined pipes.
See: https://fluids.readthedocs.io/fluids.friction.html#fluids.friction.one_phase_dP_gravitational
This example function is provided as-is without any representation of accuracy.
Args:
angle (float): Pipe angle relative to horizontal [degrees]
rho (float): Fluid density [kg/m³]
L (float, optional): Pipe length [m] Default is 1.
g (float, optional): Gravitational acceleration [m/s²] Default is 9.80665.
Returns:
float: Gravitational pressure drop. If L=1, returns per unit length [Pa/m]; otherwise total [Pa]. Returns error message (str) if input is invalid.
"""
try:
angle = float(angle)
rho = float(rho)
L = float(L)
g = float(g)
except (ValueError, TypeError):
return "Error: Could not convert parameters to required types."
if rho <= 0:
return "Error: Fluid density (rho) must be positive."
if L <= 0:
return "Error: Pipe length (L) must be positive."
if g <= 0:
return "Error: Gravitational acceleration (g) must be positive."
try:
result = fluids_dp_grav(angle=angle, rho=rho, L=L, g=g)
if result != result: # Check for NaN
return "nan"
if result == float('inf'):
return "inf"
if result == float('-inf'):
return "-inf"
return float(result)
except Exception as e:
return f"Error computing dp_grav: {str(e)}"